Skip to content

Commit

Permalink
TINSEL: Replace LockMem with GetMultiInit for MULTI_INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
somaen committed May 26, 2022
1 parent 1a2f18e commit fa8e3c5
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 22 deletions.
8 changes: 4 additions & 4 deletions engines/tinsel/bg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void BGmainProcess(CORO_PARAM, const void *param) {
pReel = (const FREEL *)param;

// Get the MULTI_INIT structure
pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
pmi = pReel->GetMultiInit();

// Initialize and insert the object, and initialize its script.
_vm->_bg->_pBG[0] = MultiInitObject(pmi);
Expand All @@ -79,7 +79,7 @@ void BGmainProcess(CORO_PARAM, const void *param) {
int i;
for (i = 0; i < _vm->_bg->_bgReels; i++) {
// Get the MULTI_INIT structure
pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pFilm->reels[i].mobj));
pmi = pFilm->reels[i].GetMultiInit();

// Initialize and insert the object, and initialize its script.
_vm->_bg->_pBG[i] = MultiInitObject(pmi);
Expand Down Expand Up @@ -138,7 +138,7 @@ void BGotherProcess(CORO_PARAM, const void *param) {
CORO_END_CONTEXT(_ctx);

const FREEL *pReel = (const FREEL *)param;
const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
const MULTI_INIT *pmi = pReel->GetMultiInit();

CORO_BEGIN_CODE(_ctx);

Expand Down Expand Up @@ -168,7 +168,7 @@ void Background::StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
const FREEL *pfr = &pfilm->reels[0];

if (TinselVersion != 3) {
const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
const MULTI_INIT *pmi = pfr->GetMultiInit();
const FRAME *pFrame = (const FRAME *)_vm->_handle->LockMem(FROM_32(pmi->hMulFrame));
const IMAGE *pim = _vm->_handle->GetImage(READ_32(pFrame));
SetBackPal(pim->hImgPal);
Expand Down
6 changes: 3 additions & 3 deletions engines/tinsel/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Cursor::InitCurTrailObj(int i, int x, int y) {

const FILM *pFilm = (const FILM *)_vm->_handle->LockMem(_cursorFilm);
const FREEL *pfr = (const FREEL *)&pFilm->reels[i + 1];
const MULTI_INIT *pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
const MULTI_INIT *pmi = pfr->GetMultiInit();

PokeInPalette(pmi);

Expand Down Expand Up @@ -303,7 +303,7 @@ void Cursor::DelAuxCursor() {
void Cursor::SetAuxCursor(SCNHANDLE hFilm) {
const FILM *pfilm = (const FILM *)_vm->_handle->LockMem(hFilm);
const FREEL *pfr = &pfilm->reels[0];
const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
const MULTI_INIT *pmi = pfr->GetMultiInit();
const FRAME *pFrame = (const FRAME *)_vm->_handle->LockMem(FROM_32(pmi->hMulFrame));
const IMAGE *pim;
int x, y; // Cursor position
Expand Down Expand Up @@ -418,7 +418,7 @@ void Cursor::DoCursorMove() {
void Cursor::InitCurObj() {
const FILM *pFilm = (const FILM *)_vm->_handle->LockMem(_cursorFilm);
const FREEL *pfr = (const FREEL *)&pFilm->reels[0];
const MULTI_INIT *pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
const MULTI_INIT *pmi = pfr->GetMultiInit();

if (TinselVersion != 3) {
PokeInPalette(pmi);
Expand Down
6 changes: 3 additions & 3 deletions engines/tinsel/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,7 @@ OBJECT *Dialogs::AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm)
auto invObj = GetInvObject(num);
const FILM *pFilm = (const FILM *)_vm->_handle->LockMem(invObj->getIconFilm());
const FREEL *pfr = (const FREEL *)&pFilm->reels[0];
const MULTI_INIT *pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
const MULTI_INIT *pmi = pfr->GetMultiInit();
OBJECT *pPlayObj; // The object we insert

*pfreel = pfr;
Expand Down Expand Up @@ -2397,7 +2397,7 @@ void Dialogs::AddTitle(OBJECT **title, const Common::Rect &bounds) {
* Insert a part of the inventory window frame onto the display list.
*/
OBJECT *Dialogs::AddObject(const FREEL *pfreel, int num) {
const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfreel->mobj));
const MULTI_INIT *pmi = pfreel->GetMultiInit();
const FRAME *pFrame = (const FRAME *)_vm->_handle->LockMem(FROM_32(pmi->hMulFrame));
const IMAGE *pim;
OBJECT *pPlayObj;
Expand Down Expand Up @@ -3144,7 +3144,7 @@ bool Dialogs::RePosition() {
void Dialogs::AlterCursor(int num) {
const FILM *pFilm = (const FILM *)_vm->_handle->LockMem(_hWinParts);
const FREEL *pfr = (const FREEL *)&pFilm->reels[num];
const MULTI_INIT *pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfr->mobj));
const MULTI_INIT *pmi = pfr->GetMultiInit();

PokeInPalette(pmi);

Expand Down
36 changes: 36 additions & 0 deletions engines/tinsel/film.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "tinsel/film.h"
#include "tinsel/handle.h"
#include "tinsel/tinsel.h"

namespace Tinsel {

MULTI_INIT *FREEL::GetMultiInit() {
return (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(mobj));
}

const MULTI_INIT *FREEL::GetMultiInit() const {
return (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(mobj));
}

} // End of namespace Tinsel
4 changes: 4 additions & 0 deletions engines/tinsel/film.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ namespace Tinsel {

#include "common/pack-start.h" // START STRUCT PACKING

struct MULTI_INIT;
struct FREEL {
SCNHANDLE mobj;
SCNHANDLE script;

MULTI_INIT *GetMultiInit();
const MULTI_INIT *GetMultiInit() const;
} PACKED_STRUCT;

struct FILM {
Expand Down
1 change: 1 addition & 0 deletions engines/tinsel/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MODULE_OBJS := \
effect.o \
events.o \
faders.o \
film.o \
font.o \
graphics.o \
handle.o \
Expand Down
6 changes: 3 additions & 3 deletions engines/tinsel/movers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ static void InitialPathChecks(MOVER *pMover, int xpos, int ypos) {

static void MoverProcessHelper(int X, int Y, int id, MOVER *pMover) {
const FILM *pfilm = (const FILM *)_vm->_handle->LockMem(pMover->walkReels[0][FORWARD]);
const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pfilm->reels[0].mobj));
const MULTI_INIT *pmi = pfilm->reels[0].GetMultiInit();

assert(_vm->_bg->BgPal()); // Can't start actor without a background palette
assert(pMover->walkReels[0][FORWARD]); // Starting actor process without walk reels
Expand Down Expand Up @@ -812,7 +812,7 @@ void T2MoverProcess(CORO_PARAM, const void *param) {
MOVER *pMover = rpos->pMover;
int i;
FILM *pFilm;
MULTI_INIT *pmi;
const MULTI_INIT *pmi;

CORO_BEGIN_CODE(_ctx);

Expand All @@ -826,7 +826,7 @@ void T2MoverProcess(CORO_PARAM, const void *param) {
InitialPathChecks(pMover, rpos->X, rpos->Y);

pFilm = (FILM *)_vm->_handle->LockMem(pMover->walkReels[i][FORWARD]); // Any old reel
pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pFilm->reels[0].mobj));
pmi = pFilm->reels[0].GetMultiInit();

// Poke in the background palette
PokeInPalette(pmi);
Expand Down
2 changes: 1 addition & 1 deletion engines/tinsel/multiobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) {
}

OBJECT *InsertReelObj(const FREEL *reels) {
const MULTI_INIT *pmi = (const MULTI_INIT*)_vm->_handle->LockMem(reels->mobj);
const MULTI_INIT *pmi = reels->GetMultiInit();
// Verify that there is an image defined
const FRAME *frame = (const FRAME*)_vm->_handle->LockMem(pmi->hMulFrame);
const IMAGE *image = (const IMAGE*)_vm->_handle->LockMem(*frame);
Expand Down
14 changes: 6 additions & 8 deletions engines/tinsel/play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,8 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,
CORO_BEGIN_CODE(_ctx);

if (actorCol) {
MULTI_INIT *pmi; // MULTI_INIT structure

pReel = GetReel(hFilm, actorCol - 1);
pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
const MULTI_INIT *pmi = pReel->GetMultiInit();
_ctx->reelActor = (int32)FROM_32(pmi->mulID);
} else
_ctx->reelActor = 0;
Expand Down Expand Up @@ -451,7 +449,7 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) {
_ctx->pfreel = &pfilm->reels[ppi->column];

// Get the MULTI_INIT structure
pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(_ctx->pfreel->mobj));
pmi = _ctx->pfreel->GetMultiInit();

// Save actor's ID
_ctx->reelActor = (int32)FROM_32(pmi->mulID);
Expand Down Expand Up @@ -705,7 +703,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA

// Get the reel and MULTI_INIT structure
_ctx->pFreel = GetReel(hFilm, column);
_ctx->pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(_ctx->pFreel->mobj));
_ctx->pmi = _ctx->pFreel->GetMultiInit();

if ((int32)FROM_32(_ctx->pmi->mulID) == -2) {
CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, hFilm, column, speed, myescEvent,
Expand Down Expand Up @@ -958,7 +956,7 @@ void NewestFilm(SCNHANDLE film, const FREEL *reel) {
const MULTI_INIT *pmi; // MULTI_INIT structure

// Get the MULTI_INIT structure
pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(reel->mobj));
pmi = reel->GetMultiInit();

if ((TinselVersion <= 1) || ((int32)FROM_32(pmi->mulID) != -2))
_vm->_actor->SetActorLatestFilm((int32)FROM_32(pmi->mulID), film);
Expand Down Expand Up @@ -1162,7 +1160,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {
// Search backwards for now as later column will be the one
for (i = (int)FROM_32(pFilm->numreels) - 1; i >= 0; i--) {
pFreel = &pFilm->reels[i];
pmi = (MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pFreel->mobj));
pmi = pFreel->GetMultiInit();
if ((int32)FROM_32(pmi->mulID) == actor) {
ppi.column = (short)i;
NewestFilm(hFilm, &pFilm->reels[i]);
Expand All @@ -1181,7 +1179,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {
int ExtractActor(SCNHANDLE hFilm) {
const FILM *pFilm = (const FILM *)_vm->_handle->LockMem(hFilm);
const FREEL *pReel = &pFilm->reels[0];
const MULTI_INIT *pmi = (const MULTI_INIT *)_vm->_handle->LockMem(FROM_32(pReel->mobj));
const MULTI_INIT *pmi = pReel->GetMultiInit();
return (int)FROM_32(pmi->mulID);
}

Expand Down

0 comments on commit fa8e3c5

Please sign in to comment.